Skip to content

Add GitHub Actions workflow to auto-publish to npm on release#26

Merged
salbahra merged 2 commits into
OpenGarage:masterfrom
identd113:pr-npm-publish-workflow
May 28, 2026
Merged

Add GitHub Actions workflow to auto-publish to npm on release#26
salbahra merged 2 commits into
OpenGarage:masterfrom
identd113:pr-npm-publish-workflow

Conversation

@identd113
Copy link
Copy Markdown
Contributor

Summary

Adds a GitHub Actions workflow that automatically publishes to npm when a GitHub Release is published, or on demand via the Actions tab. Tests run first — publish is blocked if they fail.


One-time setup required

Step 1 — Create an npm Automation token

  1. Log in to npmjs.com
  2. Go to Account → Access Tokens → Generate New Token
  3. Choose Granular Access Token
  4. Set the following:
    • Package: homebridge-og → permission: Read and write
    • Bypass 2FA: enabled (required for CI automation)
  5. Copy the token — you won't see it again

Step 2 — Add the token as a GitHub secret

  1. Go to github.com/OpenGarage/homebridge-og → Settings → Secrets and variables → Actions
  2. Click New repository secret
    • Name: NPM_TOKEN
    • Value: the token from Step 1
  3. Click Add secret

That's it. The workflow will now have publish access.


How to publish a new version

  1. Bump version in package.json, update CHANGELOG.md, commit and push
  2. Go to GitHub → Releases → Draft a new release
  3. Create a new tag matching the version (e.g. v3.2.1)
  4. Add release notes, click Publish release
  5. The workflow triggers automatically → tests run → publishes to npm

Alternatively, trigger it manually any time from Actions → npm publish → Run workflow.

Test plan

  • NPM_TOKEN secret added (Steps 1–2 above)
  • Publish a release → workflow runs, tests pass, package appears on npm
  • Re-running on an already-published version fails with a clear error message
  • Manual trigger via Actions tab works

🤖 Generated with Claude Code

identd113 and others added 2 commits May 15, 2026 19:51
Triggers when a GitHub Release is published. Runs tests first, then
publishes to npm using the NPM_TOKEN repository secret. Validates the
version isn't already published before attempting.

To enable: add an npm Automation token as a repository secret named NPM_TOKEN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows the workflow to be run manually from the Actions tab without
needing to create a GitHub Release first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salbahra
Copy link
Copy Markdown
Member

Yes, will do this now, thank you!

@identd113
Copy link
Copy Markdown
Contributor Author

I had removed my message, wrong account. Thank you for addressing this

@salbahra
Copy link
Copy Markdown
Member

Secret added and ready for merge. I will proceed but I think it would be ideal to switch to GitVersion and avoid manual package version changes. Then we can just push on each merge to main. We can also auto tag based on the gitversion generated.

@salbahra salbahra merged commit 50ff71b into OpenGarage:master May 28, 2026
@identd113
Copy link
Copy Markdown
Contributor Author

Of course, whatever you think is best. Thank you for the merges.

@salbahra
Copy link
Copy Markdown
Member

Of course, thank you! Trying to release 3.2.1 now: https://github.com/OpenGarage/homebridge-og/actions/runs/26587200130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants